// index.js
const util=require('../../utils/util')
const api=require('../../config/api')
Page({
    data: {
        banner: [],
        newGoods:[],//新品首发
        hotGoods:[],//人气推荐
        topic:[],//专题精选
        brands:[],//品牌制造商
        groupons:[],//团购专区
        floorGoods:[],//从居家开始的层级数据
        channel:[],//九宫格数据
        coupon:[],//优惠券
        goodsCount:0//商品搜索，共xx款好物

      },
      onLoad:function(options){
        this.getIndexData()
      },
      getIndexData(){
          let that=this;
          util.request(api.IndexUrl).then(function(res){
              console.log(res);
              if(res.errno==0){
                  that.setData({
                    banner:res.data.banner,
                    newGoods:res.data.newGoodsList,
                    hotGoods:res.data.hotGoodsList,
                    topic:res.data.topicList,
                    brands:res.data.brandList,
                    groupons:res.data.grouponList,
                    floorGoods:res.data.floorGoodsList,
                    channel:res.data.channel,
                    coupon:res.data.couponList,
                  })
              }
          });
          util.request(api.GoodsCount).then(function(res){
              that.setData({
                  goodsCount:res.data.goodsCount
              })
          })
      }
      
})
